package com.example.springdemo.design_model.decorator;

/**
 * 调料糖
 * @author zhangding
 * @date 2022年6月26日18:59:09
 */
public class Sugar extends Condiment{
    /**
     * 通过组合去拥有对象
     */
    Beverage beverage;

    public Sugar(Beverage beverage) {
        this.beverage = beverage;
    }

    @Override
    public double cost() {
        /**
         * 调料糖花的2.9元 再加上被被包装者花的钱
         */
        return 2.9 + beverage.cost();
    }

    @Override
    public String getDescription() {
        return beverage.getDescription() + ", sugar";
    }
}
